#!/bin/bash
set -e 
RELEASE_VERSION=$1
RELEASE_VERSION=${RELEASE_VERSION:-0.0.1}
RELEASE_BRANCH=release-$RELEASE_VERSION

echo "Release Version: $RELEASE_VERSION"
echo "Checkout to release branch $RELEASE_BRANCH"

git checkout -b $RELEASE_BRANCH
sed -i '' "s/master/$RELEASE_VERSION/g" cmd/ktctl/main.go

git add .
git commit -m "update Ktctl version to $RELEASE_VERSION"
git tag $RELEASE_VERSION
git push origin $RELEASE_VERSION

git checkout master
git branch -D $RELEASE_BRANCH
git tag -d $RELEASE_VERSION